<?php 
//echo '<pre>';
//print_r($rawdata);exit;
use Zend\Session\Container; 
$SESSION = new Container('user');
$array=array();$array1=array();$dataFinal='';
	//get money
	$money=0;
	if(isset($data['infoCustomers'][0]['money']))
	{
		$money=$data['infoCustomers'][0]['money'];
	}
?>
<!DOCTYPE html>
<html>

<div id="main-wrapper-sec">

<section>

	<!--INNER MAIN TITLE SECTION START-->

    <h2 class="inner-main-title pr-title">Deals</h2>
    
    <!--INNER MAIN TITLE SECTION END-->
    
    <!--CONTENT MAIN SECTION START-->
    
  <div class="content-main-sec">
  <!--INNER CONTENT RIGHT SECTION START-->
  <article class="deals-cont-main-sec">
  
  <h1 class="inner-cont-title">Deals</h1>
  
	<ul class="acc-sd-sec">
		<li><a href="#" onclick="contData('AS',this)" class="active" />Asia</a></li>
		<li><a href="#" onclick="contData('AM',this)" />Americas</a></li>
		<li><a href="#" onclick="contData('AF',this)" />Africa</a></li>
		<li><a href="#" onclick="contData('CA',this)" />Caribbean</a></li>
		<li><a href="#" onclick="contData('EU',this)" />Europe</a></li>
		<li><a href="#" onclick="contData('MI',this)" />Middle East</a></li>
		<li><a href="#" onclick="contData('OC',this)" />Oceania</a></li>
	</ul>
  <div class="clear"></div><br/><br/>
    <ul class="pa-fu-dt-sec">
	  <?php 
	  if(isset($pakage)){ 
		for($i=0;$i<count($pakage['infoSuites']);$i++){
			$a=substr($pakage['infoSuites'][$i]['name'],0,2);
			if($a!="PK" && $a=='AS'){
	  ?>
	<li style="text-align:center">
		<h1>
		<?php 
		if(isset($pakage['infoSuites'][$i]['name'])){
			$pakageName=explode("-",$pakage['infoSuites'][$i]['name']);	
			echo $pakageName[1];
		} 
		?>
		</h1>
		<h2><?php if(isset($pakage['infoSuites'][$i]['infoGiftTimes'][0]['giftTime'])){ echo $pakage['infoSuites'][$i]['infoGiftTimes'][0]['giftTime'];}else{ echo '0';} ?> min</h2>
		<h3><?php if(isset($pakage['infoSuites'][$i]['rentType'])){ if($pakage['infoSuites'][$i]['rentType']=="1"){ echo '30 days'; } } ?></h3>
		<h2> $<?php if(isset($pakage['infoSuites'][$i]['id'])){ $b=$pakage['infoSuites'][$i]['id']."@".$pakage['infoSuites'][$i]['rentFee'];echo $pakage['infoSuites'][$i]['rentFee']; }else{ echo '0';} ?> USD</h2>
		<p><?php if(isset($pakage['infoSuites'][$i]['memo'])){
		$memo =explode(",",$pakage['infoSuites'][$i]['memo']);
		for($j=0;$j<count($memo);$j++){
		echo $memo[$j]."<br>"; } } ?>
		</p>
		<div class="bn-but demo"><a href="javascript:void(0);" id="open-pop-up-3" onclick="ratesValues('<?php if(isset($b)){ echo $b;} ?>')">buy now</a></div>
	</li>
  <?php } } } ?>
  </ul>
  <div class="clear"></div>
  <form id="formid" method="POST" action="<?php echo $this->url('paypakage', array('action' => 'paypakage')); ?>" />
	<input type="hidden" name="money" id="money" value="<?php echo $money; ?>" />
    <input type="hidden" name="amount" id="amount" value="" />
  </form>
  <!--INNER CONTENT RIGHT SECTION END-->
    <?php if($SESSION['loginNum2']!='') { ?>
	<form id="paypal" method="post" action="<?php echo $this->url('payments', array('action' => 'payments')); ?>" />
	<?php }else{ ?>
	<form id="paypal" method="post" action="<?php echo $this->url('cpayments', array('action' => 'cpayments')); ?>" />
	<?php } ?>
	<input type="hidden" id="payers_account" name="payers_account" value="<?php if($SESSION['loginNum2']!=''){ echo $SESSION['loginNum2']; }else{
      echo $SESSION['uname']; }	?>" />
	<input type="hidden" id="payment_amount" name="payment_amount" value="" />
	</form>
  <!--CLIENTS AREA SECTION START-->
  <div class="clear"></div>
  </article>
  
  <!--INNER CONTENT RIGHT SECTION END-->
  
  </div>
  
  <!--CONTENT MAIN SECTION END-->
  
  <div class="clear"></div>
  
  <!--CLIENTS AREA SECTION START-->
  
  <aside class="content-main-sec ot-lg-sec"> <img src="<?php echo $this->basePath(); ?>/images/truste.jpg" alt=""> <img src="<?php echo $this->basePath(); ?>/images/secured.jpg" alt=""> <img src="<?php echo $this->basePath(); ?>/images/mcafeev.jpg" alt="">
    <h3 class="otg-title">Trusted. Safe. Reliable.</h3>
  </aside>
  
  <!--CLIENTS AREA SECTION END-->
  
  <div class="clear"></div>
</section>
</div>
<div id="pop-up-3" class="pop-up-display-content">
		<h2 class="popup_heding">Confirm Message</h2>
		<p class="popup_test">You are going to purchase this package and the amount will be deducted</p>
	</div>
</body>
</html>
<script>
	var data1=<?php echo $rawdata; ?>;  
	function contData(data,obj){
		var li='';var count=0;
		$.each(data1.infoSuites, function(key,value)
		{
			var a=value.name;var b='';
			var res = a.split("-");
			if(res[0]==data){
				var n="'"+value.id+"@"+value.rentFee+"'";
					if(value.rentType==1){
						b='30 days';
					}
				li=li+'<li style="text-align:center"><h1>'+res[1]+'</h1>';
				if(value.infoGiftTimes){
					$.each(value.infoGiftTimes, function(key1,value1)
					{
						if(key1='giftTime'){
						li=li+'<h2>'+value1.giftTime+' min</h2>';
						}
					});
				}
				li=li+'<h3>'+b+'</h3>';
				li=li+'<h2>'+value.rentFee+'$ USD</h2>';
				li=li+'<h3>'+value.memo+'</h3><div class="bn-but"><a href="#" onclick="ratesValues('+n+')">buy now</a></div></li>';
				count++;
			}
		});
		if(count!=0){
			$(".pa-fu-dt-sec").html(li);
			$("a").removeClass("active");
			$(obj).addClass("active");
		}else{
			$(".pa-fu-dt-sec").html('<p><br><br><br><br><br><br><br><br><br></p>');
			$("a").removeClass("active");
			$(obj).addClass("active");
		}
	}
	
	function ratesValues(id){
		var id=id;
		var arr = id.split('@');
		$('#payment_amount').val(id);
		$('#amount').val(id);
		var money=$('#money').val();
		if(money >= parseInt(arr[1])){
			$('#pop-up-3').popUpWindow({
				action: "open",
				buttons: [{
					text: "OK",
					cssClass: "btn-yes_p",
					click: function () {
						$("#formid").submit();
					}
				}, {
					text: "Cancel",
					cssClass: "btn-no_p",
					click: function () {
						this.close();
					}
				}]
			});
		}else{
			$('#pop-up-3').popUpWindow({
				action: "open",
				buttons: [{
					text: "OK",
					cssClass: "btn-yes_p",
					click: function () {
						$("#paypal").submit();
					}
				}, {
					text: "Cancel",
					cssClass: "btn-no_p",
					click: function () {
						this.close();
					}
				}]
			});
		}
		}	
</script>
















